<?php
require APPPATH."/controllers/Common.php";
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/7 0007
 * Time: 下午 3:36
 */

class AppPay extends Common
{
    public function do_weixin($code=0,$fee=0)
    {
        $code = $code?$code:$this->req('code');
        $fee = $fee?$fee:$this->req('fee');
        $fee = $fee * 100;
        define("WEIXIN_APPID", HAO_WEIXIN_APPID);
        define("WEIXIN_APPSECRET", HAO_WEIXIN_APPSECRET);
        define("WEIXIN_MCHID", HAO_WEIXIN_MCHID);
        define("WEIXIN_KEY", HAO_WEIXIN_KEY);
        $this->common_vendor('AppWxpay.WxPayApi');
        define("WX_NOTIFY_URL", APP_WX_NOTIFY_URL);
        $subject = "交易号：{$code}";
        $unifiedOrder = new \WxPayUnifiedOrder();
        $unifiedOrder->SetBody($subject);//商品或支付单简要描述
        $unifiedOrder->SetOut_trade_no($code);
        $unifiedOrder->SetTotal_fee($fee);
        $unifiedOrder->SetTrade_type("APP");
        $result = WxPayApi::unifiedOrder($unifiedOrder);
        $this->resp_api( json_encode($result) );
    }
}